﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunicationDataContract;
using System.ServiceModel;
using System.Threading;

namespace CommunicationDesktopApplication
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class DesktopCommunicationEndPoint : IDesktopCommunicationEndPointContract
    {
        public void WindowsServiceStatusChanged(Boolean running)
        {
            new Thread(new ThreadStart(() => { DesktopServiceController.Instance.IsWindowsServiceActive = running; })).Start();
        }

        public Boolean IsRunning()
        {
            return true;
        }

        public ApplicationInfo GetInformation(Guid DesktopApplicationGuid)
        {
            return new ApplicationInfo(DesktopServiceController.Instance.ApplicationId, DesktopServiceController.Instance.ApplicationColor);
        }

        public void Ping(Guid DesktopApplicationGuid)
        {
            DesktopServiceController.Instance.ApplicationIdLastPing = DesktopApplicationGuid;
        }
    }
}
